﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
namespace CrazyWorship1
{
    class DataUtils
    {
        public static string songDBFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//CrazyWorship";
        public static string songDBFile = songDBFolder + "//SongDb.dat";
        public static SongDB LoadSongDB()
        {
            SongDB db = new SongDB();
            db.ReadXml(songDBFile);
            return db;
        }
        public static void CreateDefaultSongDB()
        {
            SongDB db = new SongDB();
            db.EnforceConstraints = false;




            


            




            SongDB.SongsRow s = db.Songs.AddSongsRow(Guid.NewGuid(), "Amazing Grace", "Someone", "CreateAllCentered","FadeSongIn","FadeSongOut");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "FadeLength", "1", "Out");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "FadeTo", "0", "Out");
            
            SongDB.LyricsRow v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Amazing grace how sweet the sound", 0, "baseStyle", "ZoomFadeIn", "ZoomFadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "ZoomLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "ZoomLength", "10");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "That saved a wretch like me", 1, "baseStyle", "ZoomFadeIn", "ZoomFadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "ZoomLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "ZoomLength", "10");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "I once was lost but now am found", 2, "otherStyle", "CharacterFadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Was blind but now I see", 3, "otherStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");




            s = db.Songs.AddSongsRow(Guid.NewGuid(), "Amazing Grace2", "Someone", "CreateAllInLine", "FadeSongIn", "FadeSongOut");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "ZOffset", "-3","Creator");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Amazing grace how sweet the sound", 0, "baseStyle", "ZoomFadeIn", "ZoomFadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "ZoomLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "ZoomLength", "10");
            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "That saved a wretch like me", 1, "baseStyle", "ZoomFadeIn", "ZoomFadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "ZoomLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "ZoomLength", "10");
            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "I once was lost but now am found", 2, "otherStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "10");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "0.1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "10");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Was blind but now I see", 3, "otherStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");



            s = db.Songs.AddSongsRow(Guid.NewGuid(), "Amazing Grace - InLine/Fade Test", "Someone", "CreateAllInLine", "FadeSongIn", "FadeSongOut");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "ZOffset", "-1","Creator");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "XOffset", "-0.1", "Creator");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "YOffset", "-0.1", "Creator");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Amazing grace how sweet the sound", 0, "baseStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeTo", "0.1");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "That saved a wretch like me", 1, "baseStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeTo", "0.1");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "I once was lost but now am found", 2, "otherStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeTo", "0.1");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Was blind but now I see", 3, "otherStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeTo", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "Out", "FadeTo", "0.1");



            s = db.Songs.AddSongsRow(Guid.NewGuid(), "Video Test", "Someone", "CreateAllVideo", "FadeSongIn", "FadeSongOut");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "ZOffset", "0", "Creator");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "XOffset", "0", "Creator");
            db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), s, "YOffset", "0", "Creator");

            v = db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Amazing grace how sweet the sound", 0, "baseStyle", "FadeIn", "FadeOut");
            db.TransitionProperties.AddTransitionPropertiesRow(v, Guid.NewGuid(), "In", "FadeLength", "0");


           
            SongDB.PresetSongRow r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "Quick Fades Progressively Smaller", "CreateAllInLine");
            db.PresetCreatorAppProperties.AddPresetCreatorAppPropertiesRow(Guid.NewGuid(), r, "ZOffset", "-3","Creator");
            
            SongDB.PresetControllersRow cr=db.PresetControllers.AddPresetControllersRow(r, Guid.NewGuid(), "TextShakeController", "PanelAnimation");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "XShake", "0.25");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "YShake", "0.25");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "ZShake", "0.5");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "Duration", "200");

            SongDB.PresetAssetsRow sa = db.PresetAssets.AddPresetAssetsRow(r, Guid.NewGuid(), "TiledBackgroundAsset", "Background");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "FileName", "Images/TiledBG/04.jpg");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZOffset", "-10");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "XScale", "50");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "YScale", "50");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZScale", "50");


            SongDB.PresetLyricRow lr = db.PresetLyric.AddPresetLyricRow(r, "baseStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");


            s = db.Songs.AddSongsRow(Guid.NewGuid(), "What Can I Say shake", "Chris Vacher", "", "FadeSongIn", "FadeSongOut");

            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 0, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 1, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "You've paid the price, bought with Your life", 2, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Now I'm Yours and Yours alone", 3, "", "", "");


            ApplyPresetToSong(r, s, db);










            r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "Tiled Background Scrolling - small", "CreateAllInLine");
            db.PresetCreatorAppProperties.AddPresetCreatorAppPropertiesRow(Guid.NewGuid(), r, "ZOffset", "0", "Creator");


            sa = db.PresetAssets.AddPresetAssetsRow(r, Guid.NewGuid(), "TiledBackgroundAsset", "Background");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "FileName", "Images/TiledBG/04.jpg");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "Name", "TiledBackgroundAsset2");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZOffset", "-3");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "XScale", "0.5");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "YScale", "0.5");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZScale", "0.5");

            sa = db.PresetAssets.AddPresetAssetsRow(r, Guid.NewGuid(), "TiledBackgroundAsset", "Background");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "FileName", "Images/TiledBG/05.jpg");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "Name", "TiledBackgroundAsset1");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZOffset", "-1");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "XScale", "1");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "YScale", "1");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZScale", "1");


            cr = db.PresetControllers.AddPresetControllersRow(r, Guid.NewGuid(), "BackgroundTextureMovementController", "TextureAnimation");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "XSpeed", "1");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "YSpeed", "0");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "AssetName", "TiledBackgroundAsset2");

            cr = db.PresetControllers.AddPresetControllersRow(r, Guid.NewGuid(), "BackgroundTextureMovementController", "TextureAnimation");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "XSpeed", "-1");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "YSpeed", "1");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "AssetName", "TiledBackgroundAsset1");


            lr = db.PresetLyric.AddPresetLyricRow(r, "baseStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");


            s = db.Songs.AddSongsRow(Guid.NewGuid(), "What Can I Say tile", "Chris Vacher", "", "FadeSongIn", "FadeSongOut");

            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 0, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 1, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "You've paid the price, bought with Your life", 2, "", "", "");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "Now I'm Yours and Yours alone", 3, "", "", "");


            ApplyPresetToSong(r, s, db);







            r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "FADE - Simple", "CreateAllCentered");
            lr = db.PresetLyric.AddPresetLyricRow(r, "baseStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "BeginTime", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");







            r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "Quick Fades Both Directions", "CreateAllCentered");
            lr = db.PresetLyric.AddPresetLyricRow(r, "baseStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");


            sa = db.PresetAssets.AddPresetAssetsRow(r, Guid.NewGuid(), "TiledBackgroundAsset", "Background");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "FileName", "Images/xlarge_web.jpg");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "Tiled", "False");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "Name", "TiledBackgroundAsset2");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZOffset", "-1");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "XScale", "100");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "YScale", "100");
            db.PresetAssetProperties.AddPresetAssetPropertiesRow(sa, Guid.NewGuid(), "ZScale", "100");

            cr = db.PresetControllers.AddPresetControllersRow(r, Guid.NewGuid(), "BackgroundTextureMovementController", "TextureAnimation");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "XSpeed", "-0.05");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "YSpeed", "0");
            db.PresetControllerProperties.AddPresetControllerPropertiesRow(cr, Guid.NewGuid(), "AssetName", "TiledBackgroundAsset2");



            s = db.Songs.AddSongsRow(Guid.NewGuid(), "What Can I Say2", "Chris Vacher", "CreateAllCentered", "FadeSongIn", "FadeSongOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 0, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 1, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 2, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord",3, "baseStyle", "zoomfadeIn", "zoomfadeOut");

            ApplyPresetToSong(r, s, db);

           
            
            r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "Quick Fades Both Directions, with delay", "CreateAllCenteredWithParticles");
            lr = db.PresetLyric.AddPresetLyricRow(r, "whiteStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "BeginTime", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");





            s = db.Songs.AddSongsRow(Guid.NewGuid(), "What Can I Say Particle", "Chris Vacher", "CreateAllCentered", "FadeSongIn", "FadeSongOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 0, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 1, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 2, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 3, "baseStyle", "zoomfadeIn", "zoomfadeOut");

            ApplyPresetToSong(r, s, db);





            r = db.PresetSong.AddPresetSongRow(Guid.NewGuid(), "Create Circle", "CreateAllInCircle");
            lr = db.PresetLyric.AddPresetLyricRow(r, "baseStyle", "FadeIn", "FadeOut", Guid.NewGuid());
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "In", "FadeTo", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeLength", "1");
            db.PresetTransitionProperties.AddPresetTransitionPropertiesRow(lr, Guid.NewGuid(), "Out", "FadeTo", "0");





            s = db.Songs.AddSongsRow(Guid.NewGuid(), "What Can I Say2", "Chris Vacher", "CreateAllCentered", "FadeSongIn", "FadeSongOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 0, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 1, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 2, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 3, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 4, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 5, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "What can I say, what can I do", 6, "baseStyle", "zoomfadeIn", "zoomfadeOut");
            db.Lyrics.AddLyricsRow(s, Guid.NewGuid(), "But to say I love You Lord", 7, "baseStyle", "zoomfadeIn", "zoomfadeOut");

            ApplyPresetToSong(r, s, db);



            foreach (string f in Directory.GetFiles(".", "*.sng"))
            {
                SongDB t = new SongDB();
                t.ReadXml(f);
                db.Merge(t);
            }



            db.EnforceConstraints = true;
            if (!Directory.Exists(songDBFolder))
                Directory.CreateDirectory(songDBFolder);
            try
            {
                db.WriteXml(songDBFile);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("Directory Not Found");
            }
        }
        public static void ApplyPresetToSong(SongDB.PresetSongRow preset, SongDB.SongsRow song, SongDB db)
        {
            song.CreatorApp = preset.CreatorApp;
            foreach (SongDB.PresetCreatorAppPropertiesRow pcp in preset.GetPresetCreatorAppPropertiesRows())
            {
                db.CreatorAppProperties.AddCreatorAppPropertiesRow(Guid.NewGuid(), song, pcp.PropertyName, pcp.Value,pcp.Type);
            }
           
            foreach (SongDB.PresetAssetsRow cr in preset.GetPresetAssetsRows())
            {
                SongDB.AssetsRow control = db.Assets.AddAssetsRow(song, Guid.NewGuid(), cr.Name, cr.Type);
                foreach (SongDB.PresetAssetPropertiesRow cpr in cr.GetPresetAssetPropertiesRows())
                {
                    db.AssetProperties.AddAssetPropertiesRow(control, Guid.NewGuid(), cpr.PropertyName, cpr.Value);
                }
            }
            foreach (SongDB.PresetControllersRow cr in preset.GetPresetControllersRows())
            {
                SongDB.ControllersRow control = db.Controllers.AddControllersRow(song, Guid.NewGuid(), cr.Name, cr.Type);
                foreach (SongDB.PresetControllerPropertiesRow cpr in cr.GetPresetControllerPropertiesRows())
                {
                    db.ControllerProperties.AddControllerPropertiesRow(control, Guid.NewGuid(), cpr.PropertyName, cpr.Value);
                }
            }
            foreach (SongDB.LyricsRow lyric in song.GetLyricsRows())
            {
                lyric.InStoryBoard = preset.GetPresetLyricRows()[0].InStoryBoard;
                lyric.OutStoryBoard = preset.GetPresetLyricRows()[0].OutStoryBoard;
                lyric.Style = preset.GetPresetLyricRows()[0].Style;
                foreach (SongDB.PresetTransitionPropertiesRow ptp in preset.GetPresetLyricRows()[0].GetPresetTransitionPropertiesRows())
                {
                    db.TransitionProperties.AddTransitionPropertiesRow(lyric, Guid.NewGuid(), ptp.Type, ptp.PropertyName, ptp.Value);
                }
            }
        }
    }
}

